<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/js/boxy/js/jquery.boxy.js"></script>
<link href="/js/boxy/css/boxy.css" media="screen" rel="stylesheet" type="text/css" >  
<script type="text/javascript">
    $(function(){
        window.alert = Boxy.alert;
    });
    <?php if($this->ma == 1) { ?>
        alert("活动修改成功！");
    <?php }?>
</script>
<style>
    .newtd{ width: 200px;}    
    #edit_div {width: 80%; margin-left: 20px;font-size: 16px;}
    .edit_table{margin-top: 10px;}
    .edit_table tr{height: 36px;}
    .edit_table input,select{padding: 5px;}
    .edit_table input[type='text']{width: 60%;}
    #bf{text-align: right;}
    .wpcs{float: left;width: 100%;}
    .wupincanshu{width: 80%;}
    .wpcs table{width: 100%;}
    .wpcs table .newtd{width: 40%}
</style>
<div class="admin_nrtop">
    <div class="wupintopleft">
        <div class="wupincz">
            <div class="nui-toolbar-item">
                <div class="nui-btn ">
                    <a href="/admini/generalize/index" class="nui-btn-text"><span>&lt;&lt;</span>返回</a>
                </div>
            </div>                    
            <div class="nui-toolbar-item">
                <div class="nui-btn ">
                    <a href="javascript:void();" name="editGl" class="nui-btn-text editEp">修改信息</a>
                    <input type="hidden" id="glId" name="glId" value="<?php echo $this->generalizeItem->Id;?>" />
                </div>
                <?php if($this->generalizeItem->status == Application_Model_Generalize::Status_Default) { ?>
                    <div class="nui-btn ">
                        <a href="javascript:void();"  class="nui-btn-text EnableOrDisable" i="启用">启用</a>
                    </div>
                <?php } else { ?>
                    <div class="nui-btn ">
                        <a href="javascript:void();"  class="nui-btn-text EnableOrDisable" i="禁用">禁用</a>
                    </div>
                <?php } ?>
                 <div class="nui-btn ">
                    <a href="javascript:void();"  class="nui-btn-text handReceive">手工发放礼物</a>
                </div>
            </div>     
        </div>
    </div>
    <div style="clear:both"></div>
</div>
<div class="wupininfo" id="wupininfo" <?php echo $this->isEdit?"style='display:none;'":"";?>>
    <div class="wupincanshu">
        <div class="wpcs" style=" border-bottom:1px solid #aaa;margin-bottom: 10px;">
            <span style="font-size:20px;font-weight: 900;color: #000;">基本信息</span>
            <table style="margin-top:10px;">
                <tr>
                    <td class="tz2">活动标识：</td>	
                    <td class="newtd"><?php echo $this->generalizeItem->No; ?></td>
                </tr>
                <tr>
                    <td class="tz2" style="width:120px;">活动名称：</td>	
                    <td class="newtd"><?php echo $this->generalizeItem->Name; ?></td>
                    <td class="tz2" >状态：</td>	
                    <td class="newtd"><?php echo $this->generalizeItem->StatusName; ?></td>
                </tr>
                <tr>
                    <td class="tz2">活动内容：</td>	
                    <td colspan="3"><?php echo $this->generalizeItem->Content; ?></td>
                </tr>
                <tr>
                    <td class="tz2">活动国家：</td>	
                    <td class="newtd"><?php echo $this->generalizeItem->CityInfo?$this->generalizeItem->CityInfo->Name:"全部"; ?></td>
                    <td class="tz2">参与人数：</td>	
                    <td class="newtd"><?php echo $this->generalizeItem->ReceiveUserNum; ?></td>
                </tr>
                <tr>
                    <td class="tz2">开始时间：</td>	
                    <td><?php echo $this->generalizeItem->startTime; ?></td>
                    <td class="tz2">结束时间：</td>	
                    <td><?php echo $this->generalizeItem->endTime; ?></td>
                </tr>
            </table>
        </div>
        <div class="wpcs">
            <span style="font-size:20px;font-weight: 900;color: #000;">活动规则</span>
            <table style="margin-top:10px;">
                <?php $ruleItem = $this->generalizeItem->RuleAll;$i = 1;
                    foreach ($ruleItem as $ruleVal) { ?>
                        <tr>
                            <td class="tz2"><span style="font-size:20px;color: #0000FF;">规则-<?php echo $i;?>：</span></td>	
                            <td class="newtd"  colspan="3"></td>
                        </tr>
                        <tr>
                            <td class="tz2" style="width:120px;">推广类型：</td>	
                            <td class="newtd"><?php echo $ruleVal->GrantName; ?></td>
                            <td class="tz2" >礼物类型：</td>	
                            <td class="newtd"><?php echo $ruleVal->GiftTypeName; ?></td>
                        </tr>
                        <tr>
                            <td class="tz2">礼物名称：</td>	
                            <td class="newtd"><?php echo $ruleVal->GiftName; ?></td>
                            <td class="tz2">礼物数量：</td>	
                            <td class="newtd"><?php echo $ruleVal->Num; ?></td>
                        </tr>
                        <tr>
                            <td class="tz2">规则限制：</td>	
                            <td class="newtd"><?php echo $ruleVal->RuleLimitName; ?></td>
                            <td class="tz2">领取张数：</td>	
                            <td class="newtd"><?php echo $ruleVal->ruleNum; ?></td>
                        </tr>
                        <tr>
                            <td class="tz2">最小规则：</td>	
                            <td class="newtd"><?php echo $ruleVal->minRule; ?></td>
                            <td class="tz2">最大规则：</td>	
                            <td class="newtd"><?php echo $ruleVal->maxRule; ?></td>
                        </tr>
                        <tr>
                            <td class="tz2">发放类型：</td>	
                            <td class="newtd"><?php echo $ruleVal->GeneralizeTypeName; ?></td>
                            <td class="tz2">发放时间：</td>	
                            <td class="newtd"><?php echo $ruleVal->ReceiveTypeName; ?></td>
                        </tr>
                <?php $i++; } ?>
            </table>
            
        </div>
    </div>
    <div style="clear:both"></div>
</div>
<style>
    #edit_div table{width: 960px;font-size: 16px;}
    #edit_div table tr{height: 36px;}
    #edit_div table .bf{text-align: right;margin-right: 5px;width:120px;}
    #edit_div table input{font-size: 16px;width: 280px;}
    #edit_div table select{font-size: 16px;width: 280px;}
</style>
<div id="editdetail" <?php echo $this->isEdit?"":"style='display:none;'";?>>
    <div id="edit_div">
        <form method="post" action="/admini/generalize/generalizedetail/id/<?php echo $this->generalizeItem->Id;?>" id="formstore">
            修改推广活动信息<br>
            <table border="1" cellpadding="0" cellspacing="0">  
                <tr>
                  <td class='bf'>活动名称：</td>
                  <td class='cf' valign="middle">&nbsp;&nbsp;<input type="text" name="name" id="name"  value="<?php echo $this->generalizeItem->Name;?>"/></td>
                  <td class='bf'>活动标识：</td>
                  <td class='cf' valign="middle">&nbsp;&nbsp;<input type="text" name="no" id="no"  value="<?php echo $this->generalizeItem->No;?>"/></td>
                </tr>
                <tr>
                  <td class='bf'>活动内容：</td>
                  <td class='cf' valign="middle" colspan="3">&nbsp;&nbsp;
                      <textarea id='content' name='content' style='width:760px;height: 100px;margin-top: 10px;font-size: 16px;'><?php echo $this->generalizeItem->Content;?></textarea></td>
                </tr>
                <tr>
                  <td class='bf'>开始时间：</td>
                  <td class='cf' valign="middle">&nbsp;&nbsp;
                      <input type="text" name="startTime" id="startTime" value="<?php echo $this->generalizeItem->startTime;?>" readonly onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/></td>
                  <td class='bf'>结束时间：</td>
                  <td class='cf' valign="middle">&nbsp;&nbsp;
                      <input type="text" name="endTime" id="endTime" value="<?php echo $this->generalizeItem->endTime;?>" readonly onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/></td>
                </tr>
                <tr>
                    <td class='bf'>活动国家：</td>
                    <td class='cf selCity' valign="middle">&nbsp;&nbsp;
                        <input type="text" name="cityName" id="cityName"  value="<?php echo $this->generalizeItem->CityInfo?$this->generalizeItem->CityInfo->Name:"全部"; ?>"/>
                        <input type="hidden" name="cityId" id="cityId"  value="<?php echo $this->generalizeItem->cityId;?>"/>
                        <div class="guojiaceng" style="display:none;top: 334px;left: 158px;font-size: 14px;">
                        <div class="remen">
                                <h2>热门国家和地区</h2>
                            <ul class="countrylist">
                                <li><a href="javascript:void(0)" id="c_us" cid="0">全部</a></li>
                                <li><a href="javascript:void(0)" cid="1">美国</a></li>
                                <li><a href="javascript:void(0)" cid="2">加拿大</a></li>
                                <li><a href="javascript:void(0)" cid="3">澳大利亚</a></li>
                                <li><a href="javascript:void(0)" cid="47">日本</a></li>
                                <li><a href="javascript:void(0)" cid="39">台湾</a></li>
                                <li><a href="javascript:void(0)" cid="4">新西兰</a></li>
                                <li><a href="javascript:void(0)" cid="5">英国</a></li>
                                <li><a href="javascript:void(0)" cid="42">马来西亚</a></li>
                            </ul>
                        </div>
                        <div class="allcountry">
                            <h2>全部国家和地区</h2>
                            <ul class="countryzm">
                                <?php foreach ($this->words as $char){ ?>
                                    <li <?= $char=='A'?'class="zmon"':'' ?>><a href="javascript:void(0)"><?= $char ?></a></li>
                                <?php } ?>
                            </ul>
                            <div id="countryTab">
                                <?php foreach ($this->words as $char){ ?>
                                <ul class="countrylist"  <?= $char=='A'?'':'style="display:none"' ?>>
                                   <?php $citys= Application_Model_city::GetBySortCode($char);
                                        foreach ($citys as $city){
                                   ?>
                                    <li><a href="javascript:void(0)" cid="<?=$city->Id ?>"><?= $city->Name ?></a></li>
                                    <?php } ?>
                                </ul>
                                <?php } ?>
                            </div>
                        </div>
                    </div>
                  </td>
                  <td class='bf'>状态：</td>
                  <td class='cf' valign="middle">&nbsp;&nbsp;<select id='status' name='status'>
                          <?php foreach ($this->statusAll as $statusKey => $statusVal) { ?>
                              <option value='<?php echo $statusKey;?>' <?php echo $statusKey==$this->generalizeItem->status?"selected":"";?>><?php echo $statusVal;?></option>
                          <?php }?>
                      </select></td>
                </tr>
                <?php $i = 1;
                    foreach ($ruleItem as $ruleVal) { ?>
                        <tr class="ruleTr<?php echo $i;?>">
                          <td class='cf' colspan="4" >&nbsp;&nbsp;活动规则：
                              <?php if($i == 1){ ?><input type="hidden" id="ruleMaxNum" name="ruleMaxNum" value="<?php echo count($ruleItem);?>" />
                              <a href="javascript:void(0)" class="indexa addRule" style="margin-left:20px;">添加新规则</a><?php } ?>
                              <input type="hidden" id="ruleId" name="ruleId[]" value="<?php echo $ruleVal->Id;?>" />
                              <?php if($i > 1){ ?><a href="javascript:void(0)" class="indexa delRule" style="margin-left:20px;" i="<?php echo $i;?>">删除</a><?php } ?></td>
                        </tr>
                        <tr class="ruleTr<?php echo $i;?>">
                            <td class='bf'>推广类型：</td>
                            <td class='cf' valign="middle">&nbsp;&nbsp;<select id='grantType' name='grantType[]'>
                                    <?php foreach ($this->grantAll as $grantKey => $grantVal) { ?>
                                        <option value='<?php echo $grantKey;?>' <?php echo $grantKey==$ruleVal->grantType?"selected":"";?>><?php echo $grantVal;?></option>
                                    <?php }?>
                                </select></td>
                            <td class='bf'>礼物类型：</td>
                            <td class='cf' valign="middle">&nbsp;&nbsp;<select id='giftType' name='giftType[]'  i="<?php echo $i;?>">
                                    <?php foreach ($this->giftTypeAll as $giftTypeKey => $giftTypeVal) { ?>
                                        <option value='<?php echo $giftTypeKey;?>' <?php echo $giftTypeKey==$ruleVal->giftType?"selected":"";?>><?php echo $giftTypeVal;?></option>
                                    <?php }?>
                                </select></td>
                        </tr>
                        <tr class="ruleTr<?php echo $i;?>">
                            <td class='bf'>礼物名称：</td>
                            <td class='cf' valign="middle">&nbsp;&nbsp;<select id='giftId' name='giftId[]'  i="<?php echo $i;?>">
                                    <?php  $giftList = Application_Model_GeneralizeRule::getGiftList($ruleVal->giftType);
                                        foreach ($giftList as $giftKey => $giftVal) { ?>
                                        <option value='<?php echo $giftKey;?>' <?php echo $giftKey==$ruleVal->giftId?"selected":"";?>><?php echo $giftVal;?></option>
                                    <?php }?>
                                </select></td>
                            <td class='bf'>礼物数量：</td>
                            <td class='cf' valign="middle">&nbsp;&nbsp;<input type="text" id="giftNum" name="giftNum[]" value="<?php echo $ruleVal->num;?>" /></td>
                        </tr>
                        <tr class="ruleTr<?php echo $i;?>">
                            <td class='bf'>规则限制：</td>
                            <td class='cf' valign="middle">&nbsp;&nbsp;<select id='ruleLimit' name='ruleLimit[]' >
                                    <?php foreach ($this->ruleLimitAll as $ruleLimitKey => $ruleLimitVal) { ?>
                                        <option value='<?php echo $ruleLimitKey;?>' <?php echo $ruleLimitKey==$ruleVal->ruleLimit?"selected":"";?>><?php echo $ruleLimitVal;?></option>
                                    <?php }?>
                                </select></td>
                            <td class='bf'>领取张数：</td>
                            <td class='cf' valign="middle">&nbsp;&nbsp;<input type="text" id="ruleNum" name="ruleNum[]" value="<?php echo $ruleVal->ruleNum;?>" /></td>
                        </tr>
                        <tr class="ruleTr<?php echo $i;?>">
                            <td class='bf'>最小规则：</td>
                            <td class='cf' valign="middle">&nbsp;&nbsp;<input type="text" id="minRule" name="minRule[]" value="<?php echo $ruleVal->minRule;?>" /></td>
                            <td class='bf'>最大规则：</td>
                            <td class='cf' valign="middle">&nbsp;&nbsp;<input type="text" id="maxRule" name="maxRule[]" value="<?php echo $ruleVal->maxRule;?>" /></td>
                        </tr>
                        <tr class="ruleTr<?php echo $i;?>">
                            <td class='bf'>发放类型：</td>
                            <td class='cf' valign="middle">&nbsp;&nbsp;<select id='generalizeType' name='generalizeType[]'>
                                    <?php foreach ($this->generalizeTypeAll as $generalizeKey => $generalizeVal) { ?>
                                        <option value='<?php echo $generalizeKey;?>' <?php echo $generalizeKey==$ruleVal->generalizeType?"selected":"";?>><?php echo $generalizeVal;?></option>
                                    <?php }?>
                                </select></td>
                            <td class="bf">发放时间：</td>
                            <td class="cf" valign="middle">&nbsp;&nbsp;<select id="receiveType" name="receiveType[]">
                                    <?php foreach ($this->receiveTypeAll as $receiveKey => $receiveVal) { ?>
                                        <option value="<?php echo $receiveKey;?>"><?php echo $receiveVal;?></option>
                                    <?php }?>
                                </select></td>
                        </tr>
                    <?php $i++; } ?>
                <tr class="submitTr">
                    <td class='cf' colspan="4"  style="text-align:center;height: 50px;">
                        <input type="submit" id="submit" name="submit" value="修改" style="background-color: #FF8312;width: 100px;height: 36px;color: white;font-size: 16px;border-radius:8px;" />&nbsp;&nbsp;
                        <input type="button" id="rehref" name="rehref" value="返回" style="background-color: #1668A4;width: 100px;height: 36px;color: white;font-size: 16px;border-radius:8px;" /></td>
                </tr>
              </table>
        </form>
    </div>
</div>

<div class="wupincz wpdibu" id="wupincz">
      <div class="nui-toolbar-item">
        <div class="nui-btn ">
            <a href="/admini/generalize/index" class="nui-btn-text"><span>&lt;&lt;</span>返回<input type="hidden" id="epId" name="epId" value="<?php echo $this->generalizeItem->Id;?>" /></a>
        </div>
    </div>                    
    <div class="nui-toolbar-item">
        <div class="nui-btn ">
            <a href="javascript:void();" name="editEp" class="nui-btn-text editEp">修改信息</a>
        </div>
        <?php if($this->generalizeItem->status == Application_Model_Generalize::Status_Default) { ?>
            <div class="nui-btn ">
                <a href="javascript:void();"  class="nui-btn-text EnableOrDisable" i="启用">启用</a>
            </div>
        <?php } else { ?>
            <div class="nui-btn ">
                <a href="javascript:void();"  class="nui-btn-text EnableOrDisable" i="禁用">禁用</a>
            </div>
        <?php } ?>
        <div class="nui-btn ">
            <a href="javascript:void();"  class="nui-btn-text handReceive">手工发放礼物</a>
        </div>
    </div>   
</div>
<div class="tanchuang"  id="zzfwfinance" style="width: 760px; display: none; overflow: hidden">
    <div class="nui-msgbox">
        <div class="nui-msgbox-hd">手工发放礼物</div>
        <a class="nui-msgbox-close" title="关闭"><b></b></a>
    </div>
    <div class="wt_top">
        <div class="wt_nav">
            <ul>
                <li class="wt_on" style="display: list-item;"><a href="javascript:void(0)" id="handworkTitle">手工发放礼物</a></li>
            </ul>
        </div>
    </div>
    <div class="wenti_box" style="">
        <div class="wt_center table" style="width:700px;height: 400px;">
            <form method="post" action="/admini/generalize/receive/id/<?php echo $this->generalizeItem->Id;?>" id="formReceive">
            <table>
                <tbody>
                    <tr>
                        <td style="width: 180px;text-align: right;padding-right: 20px;">活动名称：</td>
                        <td style="width: 420px;" class="w0"><?php echo $this->generalizeItem->Name; ?></td>
                    </tr>
                    <?php $i = 1;
                        foreach ($ruleItem as $ruleVal) { ?>
                    <tr>
                        <td style="width: 180px;text-align: right;padding-right: 20px;">规则--<?php echo $i;?>：</td>
                        <td style="width: 420px;" class="w0"><?php echo $ruleVal->GrantName; ?>--<?php echo $ruleVal->RuleLimitName; ?></td>
                    </tr>
                    <tr>
                        <td style="width: 180px;text-align: right;padding-right: 20px;">参与Id：</td>
                        <td style="width: 420px;" class="w0 vaservice"><input type="text" id="receiveId" name="receiveId[<?php echo $ruleVal->Id;?>]" value="" /></td>
                    </tr>
                    <?php $i++;}?>
                    <tr>
                        <td colspan="4">
                            <div class="lctijiao" style="width: 100px;float: left;margin-left: 200px;">
                                <a class="anvbotton5" href="javascript:void(0)"><span>确认</span></a>
                            </div>
                            <div style="width: 50px;float: left;padding-top: 12px;">
                                <a href="javascript:void(0)" class="nui-btn-text retanchuang">取消</a>
                            </div>
                        </td>
                    </tr>
                </tbody></table></form>
        </div>
    </div>
</div>
<div class="houtai_overlay" style="display:none;"></div>
<script type="text/javascript">
    $(".EnableOrDisable").click(function(){
        var id = $("#glId").val();
        var i = $(this).attr("i");
        if(confirm("您确定"+i+"该活动？","提示信息")){            
            $.ajax({    
                type: 'POST',
                url: '/admini/generalize/enableordisablegl/id/'+id,
                success: function(data) {
                    if(data == 1){
                        alert(i+"成功！");
                        location.reload();
                    }else{
                        alert("发生未知错误，请重新操作");
                    }
                }
            });
        }
    });
    $(".editEp").click(function(){
        $(".wupininfo").hide();
        $("#editdetail").show();
    });
    $("#rehref").click(function(){
        $(".wupininfo").show();
        $("#editdetail").hide();
    });
    $(".selCity #cityName").click(function(){
        $('.guojiaceng').show();
    });
    $(document).bind("click",function(e){
        var target  = $(e.target);
        if(target.closest(".selCity").length == 0){
            $(".guojiaceng").hide();
        }
    });
    $('.countryzm a').each(function(index,item){
        $(item).click(function(){
            $('.countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#countryTab ul').hide();
            $('#countryTab ul').eq(index).show();
            return false;
        });
    });
    $('.countrylist a').bind('click',function(){
         var name = $(this).text();
         var cityId = $(this).attr("cid");
         $("#cityName").val(name);
         $("#cityId").val(cityId);
         $(".guojiaceng").hide();
    });
    $(".addRule").click(function(){
        var i = $(".ruleTr1 #ruleMaxNum").val();
        i++;
        var html = '<tr class="ruleTr'+i+'"><td class="cf" colspan="4" >&nbsp;&nbsp;新的活动规则：';
            html += '<a href="javascript:void(0)" class="indexa delRule" style="margin-left:20px;" i="'+i+'">删除</a></td></tr>';
            html += '<tr class="ruleTr'+i+'"><td class="bf">推广类型：</td><td class="cf" valign="middle">&nbsp;&nbsp;';
            html += '<select id="grantType" name="grantType[]">';
            <?php foreach ($this->grantAll as $grantKey => $grantVal) { ?>
            html += '<option value="<?php echo $grantKey;?>"><?php echo $grantVal;?></option>';
            <?php }?>
            html += '</select></td><td class="bf">礼物类型：</td><td class="cf" valign="middle">&nbsp;&nbsp;<select id="giftType" name="giftType[]"  i="'+i+'">';
            <?php foreach ($this->giftTypeAll as $giftTypeKey => $giftTypeVal) { ?>
            html += '<option value="<?php echo $giftTypeKey;?>"><?php echo $giftTypeVal;?></option>';
            <?php }?>
            html += '</select></td></tr><tr class="ruleTr'+i+'"><td class="bf">礼物名称：</td>';
            html += '<td class="cf" valign="middle">&nbsp;&nbsp;<select id="giftId" name="giftId[]"  i="'+i+'">';
            <?php foreach ($this->giftAll as $giftVal) { ?>
            html += '<option value="<?php echo $giftVal->Id;?>"><?php echo $giftVal->Name;?></option>';
            <?php }?>
            html += '</select></td><td class="bf">礼物数量：</td><td class="cf" valign="middle">&nbsp;&nbsp;<input type="text" id="giftNum" name="giftNum[]" value="0" /></td></tr>';
            html += '<tr class="ruleTr'+i+'"><td class="bf">规则限制：</td><td class="cf" valign="middle">&nbsp;&nbsp;<select id="ruleLimit" name="ruleLimit[]">';
            <?php foreach ($this->ruleLimitAll as $ruleLimitKey => $ruleLimitVal) { ?>
            html += '<option value="<?php echo $ruleLimitKey;?>"><?php echo $ruleLimitVal;?></option>';
            <?php }?>
            html += '</select></td><td class="bf">领取张数：</td><td class="cf" valign="middle">&nbsp;&nbsp;<input type="text" id="ruleNum" name="ruleNum[]" value="" /></td></tr>';
            html += '<tr class="ruleTr'+i+'"><td class="bf">最小规则：</td><td class="cf" valign="middle">&nbsp;&nbsp;<input type="text" id="minRule" name="minRule[]" value="" /></td>';
            html += '<td class="bf">最大规则：</td><td class="cf" valign="middle">&nbsp;&nbsp;<input type="text" id="maxRule" name="maxRule[]" value="" /></td></tr>';
            html += '<tr class="ruleTr'+i+'"><td class="bf">发放类型：</td><td class="cf" valign="middle">&nbsp;&nbsp;<select id="generalizeType" name="generalizeType[]">';
            <?php foreach ($this->generalizeTypeAll as $generalizeKey => $generalizeVal) { ?>
            html += '<option value="<?php echo $generalizeKey;?>"><?php echo $generalizeVal;?></option>';
            <?php }?>
            html += '</select></td><td class="bf">发放时间：</td><td class="cf" valign="middle">&nbsp;&nbsp;<select id="receiveType" name="receiveType[]">';
            <?php foreach ($this->receiveTypeAll as $receiveKey => $receiveVal) { ?>
            html += '<option value="<?php echo $receiveKey;?>"><?php echo $receiveVal;?></option>';
            <?php }?>
            html += '</select></td></tr>';
        $(".submitTr").before(html);
        $(".ruleTr1 #ruleMaxNum").val(i);
    });
    $(".delRule").live("click",function(){
        var i = $(this).attr("i");
        $(".ruleTr"+i).remove();
    });
    $("#giftType").live("change",function(){
        var i = $(this).attr("i");
        var type = $(this).val();
        $.post("/admini/generalize/selgift",{"type":type},function(data){
            if(data.type == 1){
                var html = "";
                $.each(data.giftItem,function(giftId,giftName){
                    html += "<option value='"+giftId+"'>"+giftName+"</option>";
                });
                $("#giftId[i='"+i+"']").html(html);
            } else {
                alert("礼物获取不出，请刷新再试！");
            }
        });
    });
    $("#submit").click(function(){
            if($("#name").val() == "") {
                alert("活动名称不能为空！");
                return false;
            } 
            if($("#no").val() == "") {
                alert("活动标识不能为空！");
                return false;
            } 
            if($("#content").val() == "") {
                alert("活动内容不能为空！");
                return false;
            } 
            if($("#startTime").val() == "") {
                alert("活动开始时间不能为空！");
                return false;
            } 
            if($("#endTime").val() == "") {
                alert("活动结束时间不能为空！");
                return false;
            } 
            return true;
        });
        $(".handReceive").click(function(){
            $("div.houtai_overlay").show();
            $("div.tanchuang").show();
        });
        $(".nui-msgbox-close,.retanchuang").live("click", function() {
            $("div.houtai_overlay").hide();
            $("div.tanchuang").hide();
        });
        $(".anvbotton5").click(function(){
            $("#formReceive").submit();
        });
</script>



